<template>
    <view class="my-input-number-field">
        <u-number-box v-model="localValue" @input="input" @change="change"></u-number-box>
    </view>
</template>

<script>
    export default {
        name: 'NumberBoxField',
        props: {
            value: {
                type: [String, Number],
                default: ''
            },
        },
        data() {
            return {
                localValue: '',
            }
        },
        methods: {
            input(value) {
                this.$emit('input', value);
            },
            change(current) {
                this.$emit('change', current.value);
            }
        },
        mounted() {
            this.localValue = this.value;
        }
    };
</script>

<style lang="scss" scoped>
    .my-input-number-field {
        height: 8rem;
        width: 100%;
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;

        .u-number-box {
            flex: 1;
            display: flex;
            justify-content: space-between;
            height: 100%;

            /deep/ .u-number-box__minus {
                flex: 0 auto;
                background: #fff !important;
                border: 1px solid #ccc;
                border-radius: 1rem;
                padding: 0 2rem !important;
                font-size: 2rem;
                height: 100% !important;
                width: 8rem !important;
            }

            /deep/ .u-number-box__input {
                flex: 1;
                background: #fff !important;
                border: 1px solid #ccc;
                border-radius: 1rem;
                padding: 0 2rem !important;
                font-size: 2rem;
                height: 100% !important;
                margin: 0 1rem;
            }

            /deep/ .u-number-box__plus {
                flex: 0 auto;
                background: #fff !important;
                border: 1px solid #ccc;
                border-radius: 1rem;
                padding: 0 2rem !important;
                font-size: 2rem;
                height: 100% !important;
                width: 8rem !important;
            }
        }
    }
</style>